#ifndef _FeedPack_H_
#define _FeedPack_H_


#define FEED_PACK_DATA_SIZE                 (FEED_FRAME_DATA_SIZE + 4)


typedef enum {
    FEED_PACK_STATE_HEAD0 = 0,
    FEED_PACK_STATE_HEAD1,
    FEED_PACK_STATE_NO,
    FEED_PACK_STATE_TYPE,
    FEED_PACK_STATE_LENGTH_LOW,
    FEED_PACK_STATE_LENGTH_HIGH,
    FEED_PACK_STATE_DATAS,
    FEED_PACK_STATE_CRC_LOW,
    FEED_PACK_STATE_CRC_HIGH,
    FEED_PACK_STATE_END,
} FeedPackStateEnum;

typedef struct{
    uint8_t head[2];                        /* 0x55AA */
    uint8_t No;                             /* 每发送1次，自动+1 */
    uint8_t channelPhy      : 4;            /* 物理通道 */
    uint8_t channelLogic    : 4;            /* 逻辑通道 */
    uint16_t length;                        /* 数据长度 */
    uint8_t datas[FEED_PACK_DATA_SIZE];     /* 数据 */
    uint16_t crc;                           /* 从head到crc前的CRC_MODBUS校验值 */
    uint16_t cnt;                           /* 已解析数据大小 */
    uint8_t state;                          /* 解析状态 */
}FeedPackType;


int8_t cFeedPackAnalysis(uint32_t uiChannel, void *pvDatas, int32_t iLength);


#endif
